using UnityEngine;
using System.Collections;

public class CameraMovement : MonoBehaviour {
	
	int moveSpeed = 1;
	int scrollSpeed = 10;
	float hSpeed = 10;
	float vSpeed = 10;
	int xmin = -50;
	int xmax = 50;
	int zmin = -25;
	int zmax = 25;
	int ymin = 0;
	int ymax = 100;
	
	void Update () {
		Vector3 newPosition = transform.position;
		
		newPosition.y += Input.GetAxis("Mouse ScrollWheel") *
			Time.deltaTime * scrollSpeed;
		
		if(Input.GetButton("left")){
			newPosition.x -=Time.deltaTime * moveSpeed;
		}
		if(Input.GetButton("right")){
			newPosition.x += Time.deltaTime * moveSpeed;
		}
		if(Input.GetButton("forward")){
			newPosition.z += Time.deltaTime * moveSpeed;
		}
		if(Input.GetButton("backward")){
			newPosition.z -= Time.deltaTime * moveSpeed;
		}
				
		newPosition.x = Mathf.Clamp(newPosition.x, xmin, xmax);
		newPosition.z = Mathf.Clamp(newPosition.z, zmin, zmax);
		newPosition.y = Mathf.Clamp(newPosition.y, ymin, ymax);
		transform.position = newPosition;
	
		if(Input.GetButton("Fire1") && Input.GetKey("left alt")){
		float heightValue = transform.position.y;
		float h = hSpeed * Input.GetAxis ("Mouse X");
		float v = vSpeed * Input.GetAxis ("Mouse Y");
		transform.Translate (h, v, 0);
		//transform.position.y = heightValue;

	}
	}
}